﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Tests
//  File name:	TestHelpers.cs
//  Developer:	Solomatov Igor
//  Created:	03.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Smart.Common;
using Smart.Common.Entities;

namespace Smart.Documents.Tests
{
	[TestClass]
	public class TestHelpers
	{
		internal enum TestEnum
		{
			Default,
			xxx,
			yyy
		}

		[TestMethod]
		public void TestHelpersMethods()
		{
			Assert.AreEqual("abcde.f ", "/a\\b'\"c«d»e#№..f ....".RemoveSpcChars());
			Assert.AreEqual("abcde.f", "/a\\b'\"c«d»e#№..f ....".RemoveSpcCharsAndSpace());
			Assert.AreEqual("abcde.f", "bbbabcbbbdcccce.fddddd".RemoveAny("bbb", "cccc", "ddddd"));
			Assert.AreEqual("abcde.f", "abcbbbdcccce.f".RemoveAny("bbb", "cccc", "ddddd"));

			// object
			Assert.AreEqual(true, DBNull.Value.IsNull() && ObjectExts.IsNull(null) && ObjectExts.IsNull(DateTime.MinValue) && ObjectExts.IsNull(Guid.Empty));
			Assert.AreEqual(false, ObjectExts.IsNull(string.Empty) || ObjectExts.IsNull(0));

			// ToXXXX
			Assert.IsNull(ObjectExts.SToStr(null));
			Assert.AreEqual("xYx", ObjectExts.SToStr("xYx"));

			Assert.AreEqual(0, ObjectExts.CvtToFloat(null));
			Assert.AreEqual(1, ObjectExts.CvtToFloat(1));
			Assert.AreEqual(1.1, ObjectExts.CvtToFloat(1.1), 0.00001);
			Assert.AreEqual(1.2, ObjectExts.CvtToFloat("1,2"), 0.00001);
			Assert.AreEqual(-1.3, ObjectExts.CvtToFloat("-1,3"), 0.00001);

			Assert.AreEqual(0, ObjectExts.CvtToDbl(null));
			Assert.AreEqual(1, ObjectExts.CvtToDbl(1));
			Assert.AreEqual(1.1, ObjectExts.CvtToDbl(1.1), 0.000000001);
			Assert.AreEqual(1.2, ObjectExts.CvtToDbl("1,2"), 0.000000001);
			Assert.AreEqual(-1.3, ObjectExts.CvtToDbl("-1,3"), 0.000000001);

			Assert.AreEqual(0, ObjectExts.CvtToInt(null));
			Assert.AreEqual(1, ObjectExts.CvtToInt(1));
			Assert.AreEqual(1, ObjectExts.CvtToInt(1.1));
			Assert.AreEqual(1, ObjectExts.CvtToInt("1"));
			Assert.AreEqual(-1, ObjectExts.CvtToInt("-1"));

			Assert.AreEqual(0, ObjectExts.CvtToLong(null));
			Assert.AreEqual(1, ObjectExts.CvtToLong(1));
			Assert.AreEqual(1, ObjectExts.CvtToLong(1.1));
			Assert.AreEqual(1, ObjectExts.CvtToLong("1"));
			Assert.AreEqual(-1, ObjectExts.CvtToLong("-1"));

			// SToXXXX
			Assert.IsNull(ObjectExts.SToStr(null));
			Assert.AreEqual("xYx", "xYx".SToStr());

			Assert.AreEqual(0, ObjectExts.SToDbl(null));
			Assert.AreEqual(1, 1.SToDbl());
			Assert.AreEqual(1.1, 1.1.SToDbl());
			Assert.AreEqual(1.2, "1,2".SToDbl());
			Assert.AreEqual(-1.3, "-1,3".SToDbl());

			Assert.AreEqual(0, ObjectExts.SToInt(null));
			Assert.AreEqual(1, 1.SToInt());
			Assert.AreEqual(1, 1.1.SToInt());
			Assert.AreEqual(1, "1".SToInt());
			Assert.AreEqual(-1, "-1".SToInt());

			Assert.AreEqual(0, ObjectExts.SToLong(null));
			Assert.AreEqual(1, 1.SToLong());
			Assert.AreEqual(1, 1.1.SToLong());
			Assert.AreEqual(1, "1".SToLong());
			Assert.AreEqual(-1, "-1".SToLong());

			Assert.AreEqual(Guid.Empty, ObjectExts.SToGuid(null));
			Assert.AreEqual(new Guid("{5B7500E4-47F8-4B1F-9E49-D89B1838F812}"),
							new Guid("{5B7500E4-47F8-4B1F-9E49-D89B1838F812}").SToGuid());
			Assert.AreEqual(new Guid("{5B7500E4-47F8-4B1F-9E49-D89B1838F812}"),
							"{5B7500E4-47F8-4B1F-9E49-D89B1838F812}".SToGuid());
			Assert.AreEqual(new Guid("{5B7500E4-47F8-4B1F-9E49-D89B1838F812}"),
							"{5B7500e4-47f8-4B1f-9E49-D89B1838F812}".SToGuid());
			Assert.AreEqual(new Guid("{5B7500E4-47F8-4B1F-9E49-D89B1838F812}"), "5B7500E4-47F8-4B1F-9E49-D89B1838F812".SToGuid());
			Assert.AreEqual(new Guid("{5B7500E4-47F8-4B1F-9E49-D89B1838F812}"), "5B7500e4-47f8-4B1f-9E49-D89B1838F812".SToGuid());

			Assert.AreEqual(TestEnum.Default, ObjectExts.SToE(null, TestEnum.Default));
			Assert.AreEqual(TestEnum.xxx, "xxx".SToE(TestEnum.Default));
			Assert.AreEqual(TestEnum.Default, "zzz".SToE(TestEnum.Default));

			Assert.AreEqual(false, ObjectExts.SToBool(null));
			Assert.AreEqual(true, "true".SToBool());
			Assert.AreEqual(false, "false".SToBool());
			Assert.AreEqual(false, "истина".SToBool());
			Assert.AreEqual(false, "ложь".SToBool());
			Assert.AreEqual(false, 1.SToBool());
			Assert.AreEqual(false, 0.SToBool());

			Assert.AreEqual(DateTime.MinValue, ObjectExts.SToDT(null));
			Assert.AreEqual(DateTime.MinValue, "test".SToDT());
			Assert.AreEqual(new DateTime(2011, 02, 01), new DateTime(2011, 02, 01).SToDT());
			Assert.AreEqual(new DateTime(2011, 02, 01), "01.02.2011".SToDT());
			Assert.AreEqual(new DateTime(2011, 02, 01, 11, 10, 0), "01.02.2011 11:10".SToDT());
			Assert.AreEqual(new DateTime(2011, 02, 01, 11, 10, 9), "01.02.2011 11:10:9".SToDT());
			Assert.AreEqual(new DateTime(2011, 02, 01, 11, 10, 9, 888), "01.02.2011 11:10:9.888".SToDT());

			Assert.AreEqual(TimeSpan.MinValue, ObjectExts.SToTS(null));
			Assert.AreEqual(TimeSpan.MinValue, "test".SToTS());
			Assert.AreEqual(new TimeSpan(0, 01, 02, 03), new TimeSpan(0, 01, 02, 03).SToTS());
			Assert.AreEqual(new TimeSpan(0, 01, 02, 03), "01:02:03".SToTS());
			Assert.AreEqual(new TimeSpan(99, 01, 02, 03), "99.01:02:03".SToTS());

			// Format text
			Assert.AreEqual("сто один", H.FormatText(101.10, false));
			Assert.AreEqual("минус двести пять", H.FormatText(-205.15, false));
			Assert.AreEqual("семьсот двадцать семь рублей 09 копеек", H.FormatText(727.09, true));
			Assert.AreEqual("минус восемьсот девяносто пять рублей 99 копеек", H.FormatText(-895.99, true));
			Assert.AreEqual(
				"минус двадцать три миллиарда пятьсот семьдесят миллионов восемьсот тридцать семь тысяч пятьсот сорок пять",
				H.FormatText(-23570837545.99, false));
			Assert.AreEqual(
				"пять миллиардов четыреста восемьдесят четыре миллиона шестьсот восемнадцать тысяч восемьсот сорок семь",
				H.FormatText(5484618847.80, false));
			Assert.AreEqual(
				"девяносто семь миллиардов пятьсот сорок восемь миллионов сто двадцать четыре тысячи восемьсот четырнадцать",
				H.FormatText(97548124814.80, false));
			Assert.AreEqual("один миллион два", H.FormatText(1000002, false));
			Assert.AreEqual("два миллиона один", H.FormatText(2000001, false));

			// bytes <--> string
			Assert.AreEqual(true, Equals(null, StringExts.ToBytes(null)));
			Assert.AreEqual(true, Equals(new byte[0], StringExts.ToBytes(string.Empty)));
			Assert.AreEqual(true, Equals(new byte[] { 50, 116, 101, 120, 116, 242, 229, 234, 241, 242, 50 }, StringExts.ToBytes("2textтекст2")));

			Assert.AreEqual(true, Equals(null, StringExts.ToString(null)));
			Assert.AreEqual(true, Equals(string.Empty, StringExts.ToString(new byte[0])));
			Assert.AreEqual(true, Equals("1textтекст1", StringExts.ToString(new byte[] { 49, 116, 101, 120, 116, 242, 229, 234, 241, 242, 49 })));

			// Patch folder name
			Assert.AreEqual(null, PathExts.PatchFolderName(null));
			Assert.AreEqual(string.Empty, PathExts.PatchFolderName(string.Empty));
			Assert.AreEqual(@"C:\Folder\", PathExts.PatchFolderName(@"C:\Folder"));
			Assert.AreEqual(@"C:\Folder\", PathExts.PatchFolderName(@"C:\Folder\"));

			// Strings checks
			Assert.AreEqual(true, ((string)null).IsNullOrEmpty());
			Assert.AreEqual(true, string.Empty.IsNullOrEmpty());
			Assert.AreEqual(true, "".IsNullOrEmpty());
			Assert.AreEqual(false, "xxx".IsNullOrEmpty());

			Assert.AreEqual(true, H.IsAnyNullOrEmpty(null, string.Empty, "xxx"));
			Assert.AreEqual(true, H.IsAnyNullOrEmpty("zzz", string.Empty, "xxx"));
			Assert.AreEqual(true, H.IsAnyNullOrEmpty(null, "", "xxx"));
			Assert.AreEqual(true, H.IsAnyNullOrEmpty("zzz", "", "xxx"));
			Assert.AreEqual(true, H.IsAnyNullOrEmpty(null, "yyy", "xxx"));
			Assert.AreEqual(false, H.IsAnyNullOrEmpty("zzz", "yyy", "xxx"));

			Assert.AreEqual(true, string.Empty.Eq(""));
			Assert.AreEqual(true, StringExts.Eq(null, null));
			Assert.AreEqual(false, "".Eq(null));
			Assert.AreEqual(false, StringExts.Eq(null, ""));
			Assert.AreEqual(true, "xxxУУУ".Eq("xxxУУУ"));
			Assert.AreEqual(false, "xXxУУУ".Eq("xxxУУУ"));
			Assert.AreEqual(false, "xxxУуУ".Eq("xxxУУУ"));
			Assert.AreEqual(false, "xxxУУУ1".Eq("xxxУУУ2"));
			Assert.AreEqual(false, "xxxУУУ1".Eq("xxxУУУ"));
			Assert.AreEqual(false, "xxxУУУ".Eq("xxxУУУ2"));

			Assert.AreEqual(true, string.Empty.EqIC(""));
			Assert.AreEqual(true, StringExts.EqIC(null, null));
			Assert.AreEqual(false, "".EqIC(null));
			Assert.AreEqual(false, StringExts.EqIC(null, ""));
			Assert.AreEqual(true, "xxxУУУ".EqIC("xxxУУУ"));
			Assert.AreEqual(true, "xXxУУУ".EqIC("xxxУУУ"));
			Assert.AreEqual(true, "xxxУуУ".EqIC("xxxУУУ"));
			Assert.AreEqual(false, "xxxУУУ1".Eq("xxxУУУ2"));
			Assert.AreEqual(false, "xxxУУУ1".Eq("xxxУУУ"));
			Assert.AreEqual(false, "xxxУУУ".Eq("xxxУУУ2"));

			// String operators
			Assert.AreEqual("abc", "abcdef".SubstringTo("d"));
			Assert.AreEqual("abc", "abcdef".SubstringTo("de"));
			Assert.AreEqual("abc", "abcdef".SubstringTo("def"));

			Assert.AreEqual("abc", "abcdef".SubstringTo('d'));
			Assert.AreEqual("abc", "abcdef".SubstringTo('d', 'e'));
			Assert.AreEqual("abc", "abcedf".SubstringTo('d', 'e'));
			Assert.AreEqual("abc", "abcfed".SubstringTo('d', 'e', 'f'));

			string v1, v2;
			"abC;#deF".DispatchDelimitValue(";#", out v1, out v2);
			Assert.AreEqual("abC", v1);
			Assert.AreEqual("deF", v2);

			"C;#d".DispatchDelimitValue(";#", out v1, out v2);
			Assert.AreEqual("C", v1);
			Assert.AreEqual("d", v2);

			"abC;#".DispatchDelimitValue(";#", out v1, out v2);
			Assert.AreEqual("abC", v1);
			Assert.AreEqual("", v2);

			"abC".DispatchDelimitValue(";#", out v1, out v2);
			Assert.AreEqual("abC", v1);
			Assert.AreEqual("", v2);

			";#deF".DispatchDelimitValue(";#", out v1, out v2);
			Assert.AreEqual("", v1);
			Assert.AreEqual("deF", v2);

			"abC;deF".DispatchDelimitValue(";", out v1, out v2);
			Assert.AreEqual("abC", v1);
			Assert.AreEqual("deF", v2);

			"C;d".DispatchDelimitValue(";", out v1, out v2);
			Assert.AreEqual("C", v1);
			Assert.AreEqual("d", v2);

			"abC;".DispatchDelimitValue(";", out v1, out v2);
			Assert.AreEqual("abC", v1);
			Assert.AreEqual("", v2);

			";deF".DispatchDelimitValue(";", out v1, out v2);
			Assert.AreEqual("", v1);
			Assert.AreEqual("deF", v2);

			Assert.AreEqual(true, 'a'.In('a', 'b', 'c'));
			Assert.AreEqual(true, 'b'.In('a', 'b', 'c'));
			Assert.AreEqual(true, 'c'.In('a', 'b', 'c'));
			Assert.AreEqual(false, 'd'.In('a', 'b', 'c'));

			Assert.AreEqual(false, 'a'.Out('a', 'b', 'c'));
			Assert.AreEqual(false, 'b'.Out('a', 'b', 'c'));
			Assert.AreEqual(false, 'c'.Out('a', 'b', 'c'));
			Assert.AreEqual(true, 'd'.Out('a', 'b', 'c'));

			Assert.AreEqual(true, "aa".In("aa", "bbb", "cccc"));
			Assert.AreEqual(true, "bbb".In("aa", "bbb", "cccc"));
			Assert.AreEqual(true, "cccc".In("aa", "bbb", "cccc"));
			Assert.AreEqual(false, "ddd".In("aa", "bbb", "cccc"));

			Assert.AreEqual(false, "aa".Out("aa", "bbb", "cccc"));
			Assert.AreEqual(false, "bbb".Out("aa", "bbb", "cccc"));
			Assert.AreEqual(false, "cccc".Out("aa", "bbb", "cccc"));
			Assert.AreEqual(true, "ddd".Out("aa", "bbb", "cccc"));

			Assert.AreEqual("00001234", "1234".EnsureLength(8));
			Assert.AreEqual("12345678", "12345678".EnsureLength(8));
			Assert.AreEqual("1234    ", "1234".EnsureLength(8, false, ' '));
			Assert.AreEqual("12345678", "12345678".EnsureLength(8, false, ' '));

			Assert.AreEqual("/xxx/", "xxx".EnsureStartsWith("/").EnsureEndsWith("/"));
			Assert.AreEqual("/xxx/", "xxx".EnsureEndsWith("/").EnsureStartsWith("/"));
			Assert.AreEqual("/xxx\\", "xxx".EnsureStartsWith("/").EnsureEndsWith("\\"));
			Assert.AreEqual("/xxx\\", "xxx".EnsureEndsWith("\\").EnsureStartsWith("/"));
			Assert.AreEqual("aaxxxbb", "xxx".EnsureStartsWith("aa").EnsureEndsWith("bb"));
			Assert.AreEqual("/", "".EnsureStartsWith("/").EnsureEndsWith("/"));
			Assert.AreEqual("/", "".EnsureStartsWith("/"));
			Assert.AreEqual("/", "".EnsureEndsWith("/"));
			Assert.AreEqual("aaaaxxx", "xxx".EnsureStartsWith("aaaa"));
			Assert.AreEqual("xxxbbbb", "xxx".EnsureEndsWith("bbbb"));

			Assert.AreEqual("xxx", "xxx".TrimStart("/"));
			Assert.AreEqual("xxx", "/xxx".TrimStart("/"));
			Assert.AreEqual("xxx/", "/xxx/".TrimStart("/"));
			Assert.AreEqual("xxx", "xxx".TrimEnd("/"));
			Assert.AreEqual("xxx", "xxx/".TrimEnd("/"));
			Assert.AreEqual("/xxx", "/xxx/".TrimEnd("/"));
			Assert.AreEqual("xxx", "xxx".TrimStart("aa"));
			Assert.AreEqual("xxx", "aaxxx".TrimStart("aa"));
			Assert.AreEqual("xxx", "xxx".TrimEnd("aa"));
			Assert.AreEqual("xxx", "xxxaa".TrimEnd("aa"));
			Assert.AreEqual("xxx", "xxx".TrimStart("aaaa"));
			Assert.AreEqual("xxx", "aaaaxxx".TrimStart("aaaa"));
			Assert.AreEqual("xxx", "xxx".TrimEnd("aaaa"));
			Assert.AreEqual("xxx", "xxxaaaa".TrimEnd("aaaa"));

			Assert.AreEqual("xxx", "xxx".LimitLength(8));
			Assert.AreEqual("xxxYY...", "xxxYYYYYY".LimitLength(8));

			// DoSS, DeSS
			Assert.AreEqual("\r\nabc\t \r\nabcd\t\r\\\"ss\nn\r\n", StringExts.DeSS(StringExts.DoSS("\r\nabc\t \r\nabcd\t\r\\\"ss\nn\r\n")));

			// Replace DCS
			var values = new Dictionary<string, string> { { "test1", "val1" }, { "test2", "value2" }, { "test3", "testX" } };

			Assert.AreEqual(null, StringExts.ReplaceTags(null, values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("", StringExts.ReplaceTags("", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("test", StringExts.ReplaceTags("test", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("test1", StringExts.ReplaceTags("test1", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("##", StringExts.ReplaceTags("##", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("1##2", StringExts.ReplaceTags("1##2", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("1 ## 2", StringExts.ReplaceTags("1 ## 2", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("####", StringExts.ReplaceTags("####", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual(" #### ", StringExts.ReplaceTags(" #### ", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("1####2", StringExts.ReplaceTags("1####2", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("1 #### 2", StringExts.ReplaceTags("1 #### 2", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("val1", StringExts.ReplaceTags("##test1##", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual(" val1 ", StringExts.ReplaceTags(" ##test1## ", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("val1test2##", StringExts.ReplaceTags("##test1##test2##", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("val1 value2", StringExts.ReplaceTags("##test1## ##test2##", values, Smart.Common.Const.Template.TagSymbol));
			Assert.AreEqual("##testX## testX", StringExts.ReplaceTags("##testX## ##test3##", values, Smart.Common.Const.Template.TagSymbol));

			// Collections
			var lvc1 = new LookupValueCollection { new LookupValue(1), new LookupValue(2), new LookupValue(3) };

			Assert.AreEqual(true, lvc1.Equals(new Identifier[] { 1, 2, 3 }));
			Assert.AreEqual(true, lvc1.Equals(new Identifier[] { 2, 3, 1 }));
			Assert.AreEqual(true, lvc1.Equals(new Identifier[] { 2, 3, 1, 1 }));
			Assert.AreEqual(true, lvc1.Equals(new Identifier[] { 1, 2, 3 }));
			Assert.AreEqual(true, lvc1.Equals(new Identifier[] { 2, 1, 2, 3 }));
			Assert.AreEqual(true, lvc1.Equals(new Identifier[] { 3, 1, 2 }));
			Assert.AreEqual(false, lvc1.Equals(new Identifier[] { 1, 2, 3, 4, 4 }));
			Assert.AreEqual(false, lvc1.Equals(new Identifier[] { 1, 2, 4 }));
			Assert.AreEqual(false, lvc1.Equals(new Identifier[] { 1, 2 }));
			Assert.AreEqual(false, lvc1.Equals(new Identifier[] { 1, 2, 1 }));
			Assert.AreEqual(false, lvc1.Equals(new Identifier[] { 1 }));
			Assert.AreEqual(false, lvc1.Equals(new Identifier[] { 1, 1, 1 }));

			var lvc2 = new LookupValueCollection();

			Assert.AreEqual(true, lvc2.Equals(new Identifier[] { }));
			Assert.AreEqual(false, lvc2.Equals(new Identifier[] { 1 }));

			var uvc1 = new UserValueCollection { new UserValue(1), new UserValue(2), new UserValue(3) };

			Assert.AreEqual(true, uvc1.Equals(new Identifier[] { 1, 2, 3 }));
			Assert.AreEqual(true, uvc1.Equals(new Identifier[] { 2, 3, 1 }));
			Assert.AreEqual(true, uvc1.Equals(new Identifier[] { 2, 3, 1, 1 }));
			Assert.AreEqual(true, uvc1.Equals(new Identifier[] { 1, 2, 3 }));
			Assert.AreEqual(true, uvc1.Equals(new Identifier[] { 2, 1, 2, 3 }));
			Assert.AreEqual(true, uvc1.Equals(new Identifier[] { 3, 1, 2 }));
			Assert.AreEqual(false, uvc1.Equals(new Identifier[] { 1, 2, 3, 4, 4 }));
			Assert.AreEqual(false, uvc1.Equals(new Identifier[] { 1, 2, 4 }));
			Assert.AreEqual(false, uvc1.Equals(new Identifier[] { 1, 2 }));
			Assert.AreEqual(false, uvc1.Equals(new Identifier[] { 1, 2, 1 }));
			Assert.AreEqual(false, uvc1.Equals(new Identifier[] { 1 }));
			Assert.AreEqual(false, uvc1.Equals(new Identifier[] { 1, 1, 1 }));

			var uvc2 = new LookupValueCollection();

			Assert.AreEqual(true, uvc2.Equals(new Identifier[] { }));
			Assert.AreEqual(false, uvc2.Equals(new Identifier[] { 1 }));

			var cvc1 = new ChoiceValueCollection { "choicE1", "выбОр2" };

			Assert.AreEqual(true, cvc1.Equals(new[] { "choice1", "выбор2" }));
			Assert.AreEqual(true, cvc1.Equals(new[] { "choicE1", "выбОр2" }));
			Assert.AreEqual(true, cvc1.Equals(new[] { "выбОр2", "choicE1" }));
			Assert.AreEqual(true, cvc1.Equals(new[] { "choicE1", "выбОр2", "choice1", "выбор2" }));
			Assert.AreEqual(false, cvc1.Equals(new[] { "choice1", "выбор2", "choice2" }));
			Assert.AreEqual(false, cvc1.Equals(new[] { "choice1", "выбор3" }));
			Assert.AreEqual(false, cvc1.Equals(new[] { "choice1" }));

			var cvc2 = new ChoiceValueCollection();

			Assert.AreEqual(true, cvc2.Equals(new string[] { }));
			Assert.AreEqual(false, cvc2.Equals(new[] { "choice1" }));
		}

		public bool Equals(byte[] fst, byte[] snd)
		{
			if (fst == null && snd == null)
				return true;

			if (fst == null || snd == null)
				return false;

			if (fst.Length != snd.Length)
				return false;

			for (var I = 0; I < fst.Length; I++)
			{
				if (fst[I] != snd[I])
					return false;
			}

			return true;
		}
	}
}